package com.ruoyi.service.impl;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.domain.BasisGroundEnvironment;
import com.ruoyi.domain.BasisPosition;
import com.ruoyi.dto.BasisLoadingPositionCamp;
import com.ruoyi.dto.BasisLoadingPositionWeather;
import com.ruoyi.mapper.BasisPositionMapper;
import com.ruoyi.service.IBasisPositionService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 阵地数据管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-05-23
 */
@Service
public class BasisPositionServiceImpl implements IBasisPositionService
{
    @Autowired
    private BasisPositionMapper basisPositionMapper;

    /**
     * 查询阵地数据管理
     * 
     * @param id 阵地数据管理主键
     * @return 阵地数据管理
     */
    @Override
    public BasisPosition selectBasisPositionById(Long id)
    {
        return basisPositionMapper.selectBasisPositionById(id);
    }

    public BasisPosition selectBasisPositionByUserID (@Param("loadingId") String loadingId, @Param("userid") Long userid){
        return basisPositionMapper.selectBasisPositionByUserID(loadingId,userid);
    }

    /**
     * 查询阵地数据管理列表
     * 
     * @param basisPosition 阵地数据管理
     * @return 阵地数据管理
     */
    @Override
    public List<BasisPosition> selectBasisPositionList(BasisPosition basisPosition)
    {
        return basisPositionMapper.selectBasisPositionList(basisPosition);
    }

    /**
     * 新增阵地数据管理
     * 
     * @param basisPosition 阵地数据管理
     * @return 结果
     */
    @Override
    public int insertBasisPosition(BasisPosition basisPosition)
    {

        SysUser user = SecurityUtils.getLoginUser().getUser();
        basisPosition.setUserId(user.getUserId());
        basisPosition.setCreateTime(new Date());

//        int i = basisPositionMapper.insertBasisPosition(basisPosition);
//        if (i > 0){
//
//        }
        return basisPositionMapper.insertBasisPosition(basisPosition);
    }

    /**
     * 修改阵地数据管理
     * 
     * @param basisPosition 阵地数据管理
     * @return 结果
     */
    @Override
    public int updateBasisPosition(BasisPosition basisPosition)
    {
        return basisPositionMapper.updateBasisPosition(basisPosition);
    }

    /**
     * 批量删除阵地数据管理
     * 
     * @param ids 需要删除的阵地数据管理主键
     * @return 结果
     */
    @Override
    public int deleteBasisPositionByIds(Long[] ids)
    {
        return basisPositionMapper.deleteBasisPositionByIds(ids);
    }

    /**
     * 删除阵地数据管理信息
     * 
     * @param id 阵地数据管理主键
     * @return 结果
     */
    @Override
    public int deleteBasisPositionById(Long id)
    {
        return basisPositionMapper.deleteBasisPositionById(id);
    }

//    @Override
//    public boolean configPositionAndWeather(BasisLoadingPositionWeather basisLoadingPositionWeather) {
//        return basisPositionMapper.configPositionAndWeather(basisLoadingPositionWeather);
//    }

    @Override
    public boolean addBasisLoadingPositionCamp(BasisLoadingPositionCamp basisLoadingPositionCamp) {
        return basisPositionMapper.addBasisLoadingPositionCamp(basisLoadingPositionCamp);
    }

    @Override
    public boolean updateBasisLoadingPositionCamp(BasisLoadingPositionCamp basisLoadingPositionCamp) {
        return basisPositionMapper.updateBasisLoadingPositionCamp(basisLoadingPositionCamp);
    }

    @Override
    public Map<String,Object> findByBasisLoadingPositionCamp(String loadingId, Integer positionId) {
        return basisPositionMapper.findByBasisLoadingPositionCamp(loadingId, positionId);
    }

    @Override
    public boolean delBasisLoadingPositionCamp(String loadingId, Integer positionId) {
        return basisPositionMapper.delBasisLoadingPositionCamp(loadingId, positionId);
    }

    @Override
    public boolean delBasisPositionEquipmentUser(String loadingId, Integer positionId) {
        return basisPositionMapper.delBasisPositionEquipmentUser(loadingId, positionId);
    }



    @Override
    public boolean delBasisPositionUser(String loadingId, Integer positionId) {
        return basisPositionMapper.delBasisPositionUser(loadingId, positionId);
    }
    //根据案例id和阵营id查询阵地
    @Override
    public List<BasisPosition> findByLoadingIdAndCampId(String loadingId, String campId) {
        return basisPositionMapper.findByLoadingIdAndCampId(loadingId, campId);
    }

    @Override
    public List<BasisPosition> selectBasisPositionFormLoadingId(String loadingId) {
        return basisPositionMapper.selectBasisPositionFormLoadingId(loadingId);
    }

    @Override
    public BasisPosition getByUuid(String uuid) {
        return basisPositionMapper.getByUuid(uuid);
    }

}
